/**
 * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
 *
 * 求字符串中连续出现最多的字符序列
 * @param input string字符串 输入字符串
 * @return string字符串
 */
function getLongestSequence (input) {
  // write code here
  let start = 0
  let end = 0
  let resCount = 0
  let resChar = input[0]
  while (end < input.length) {
    let str = input[start] // 记录当前的字符
    if (str !== input[++end]) { // 如果不相同
      let count = end - start// 出现的次数
      if (count > resCount) {
        resCount = count
        resChar = str
      }
      start = end // 开始和结束在相同的位置
    }
  }
  let result = ''
  for (let i = 0; i < resCount; i++) {
    result += resChar
  }
  return result
}
console.log(getLongestSequence('abbcccdeff'));
module.exports = {
  getLongestSequence: getLongestSequence
};